﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using jSLApp.Client.ApplicationBase;
using jSLApp.Client.Forms;
using jSLApp.Client.MainService;
using jSLCore.Client.Presentation.ApplicationContainer;
using jSLCore.Client.Presentation.BaseControl.Selection;

namespace jSLApp.Client.Controls
{
    public partial class MusicGrid : jSLGrid
    {
        public MusicGrid()
        {
            InitializeComponent();
            Style = (Style) Resources["selGrid"];
        }
        
        private void Play_Song(object sender, RowSelectedEventArgs e)
        {
            var music = (Music)e.RowObject;
            ((MainContentContainer)ApplicationContainer.CurrentContentContainer).PlayMusic(music.FullFileName, music.AuthorName + " - " + music.Name, music.id);
        }

        private void download_Clicked(object sender, RoutedEventArgs e)
        {
            var element = (FrameworkElement)sender;
            var music = (Music) element.DataContext;

            ((MainContentContainer)ApplicationContainer.CurrentContentContainer).DownloadMusic(music.id);  
        }

        private void goto_Details(object sender, RowSelectedEventArgs e)
        {
            var music = (Music)e.RowObject;
            var det = new MusicDetail(music.id);
            ApplicationContainer.CurrentContentContainer.ShowPage(det,false);
        }
    }
}
